import {ref} from 'vue'
import{defineStore} from 'pinia'
import { Operate } from '../utils/utils'

export const useOperateMapStore = defineStore('operateMap',()=>{
    let operateMap = ref<Map<string,Operate>>(new Map<string,Operate>())

    // function initMap(){
    //     // clear current list
    //     operateMap.value.set(':C',{msg:'',processLocate:ProcessLocate.local,fuc:()=>{return}})
    //     // translate previous text to English
    //     operateMap.value.set(':T',{msg:'in English',processLocate:ProcessLocate.local,fuc:()=>{return}})
    //     // translate previous text to Chinese
    //     operateMap.value.set(':TC',{msg:'in Chinese',processLocate:ProcessLocate.local,fuc:()=>{return}})
    //     // ask llm think and response again
    //     operateMap.value.set(':R',{msg:'找出回答中的问题并重新生成',processLocate:ProcessLocate.local,fuc:()=>{return}})

    // }  

    function insert(key:string,value:Operate){
        operateMap.value.set(key,value)
    }
    function has(key:string):boolean{
        return operateMap.value.has(key)
    }
    function execute(key:string){
        operateMap.value.get(key)?.fuc()
        // return operateMap.value.get(key)
    }
    return {
        operateMap,
        insert,
        has,
        execute,
        // initMap
    }
})